/**
 * Copyright (c) [2022] [yanyeori]
 * [yanyeori-service] is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package com.yanyeori.service.file.api.client;

import com.yanyeori.framework.core.model.WebResponse;
import com.yanyeori.service.file.api.constant.FileConst;
import com.yanyeori.service.file.api.dto.FileDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * OSS文件客户端
 *
 * @author chenkuan
 * @since 2022/10/6 14:38
 */
@FeignClient(value = FileConst.APPLICATION_NAME, contextId = "ossFileClient")
@RequestMapping("/ossFileController")
public interface OssFileClient {

    /**
     * 文件上传接口
     *
     * @param file 上传的文件
     * @return 文件上传信息
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    WebResponse<FileDTO> upload(@RequestPart("file") MultipartFile file);

    /**
     * 获取文件下载链接
     *
     * @param filePath 文件路径
     * @return 访问地址
     */
    @GetMapping("/getDownloadUrl")
    WebResponse<String> getDownloadUrl(@RequestParam("filePath") String filePath);
}
